<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <title>个人头像</title>
    <link rel="stylesheet" href="../../css/index.css" />
    <link rel="stylesheet" href="../../css/weui.css" />
    <link rel="stylesheet" href="../../css/reservateLog.css" />
    <script type="text/javascript" src="../../js/jquery-1.10.1.js"></script>
    <script type="text/javascript" src="../../js/weui/zepto.min.js"></script>
    <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script src="https://res.wx.qq.com/open/libs/weuijs/1.0.0/weui.min.js"></script>
</head>
<body style="background-color: #f8f8f8">
<div id="personalCenter">
    <a href="javascript:;" class="weui-panel" style="color: #313131;" id="showIOSActionSheet">
        <div class="weui-panel__bd">
            <div class="weui-media-box weui-media-box_small-appmsg">
                <div class="weui-cells" style="background-color: #f8f8f8">
                    <div class="weui-cell weui-cell_access" style="padding: 6px 15px;background-color: #fff">
                        <div class="weui-cell__bd weui-cell_primary">
                            <p>头像</p>
                        </div>
                        <div id="headPicture" class="weui-cell__hd"><img src="../../images/daohang2.jpg" alt="" style="width:55px;margin-right:5px;display:block"></div>
                    </div>
                </div>
            </div>
        </div>
    </a>
</div>
<div>
    <div class="weui-mask" id="iosMask"></div>
    <div class="weui-actionsheet" id="iosActionsheet" style="position: fixed;bottom: 150px">
        <div class="weui-actionsheet__menu">
            <div class="weui-actionsheet__cell camera">拍照</div>
            <div class="weui-actionsheet__cell album">从手机相册选择</div>
        </div>
        <a href="setting.html" style="display: block;color: #000000" class="weui-actionsheet__action">
            <div class="weui-actionsheet__cell" id="iosActionsheetCancel">取消</div>
        </a>
    </div>
</div>
<script>
    wx.config({
        debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
        appId: appId, // 必填，企业号的唯一标识，此处填写企业号corpid
        timestamp: timestamp, // 必填，生成签名的时间戳
        nonceStr: noncestr, // 必填，生成签名的随机串
        signature: signature, // 必填，签名，见附录1
        jsApiList: ['checkJsApi',
            'chooseImage'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
    });
    wx.checkJsApi({
        jsApiList: [
            'chooseImage'
        ],
        success: function (res) {
            // alert(JSON.stringify(res.checkResult.getLocation));
            if (res.checkResult.getLocation == false) {
                alert('你的微信版本太低，不支持微信JS接口，请升级到最新的微信版本！');
                return;
            }
        }
    });
    $('#iosMask').click(function(){
        location.href = 'setting.html';
    })
   $('.camera').click(function(){
       wx.chooseImage({
           count: 1, // 默认9
           sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
           sourceType: ['camera'], // 可以指定来源是相册还是相机，默认二者都有
           success: function (res) {
               var localIds = res.localIds; // 返回选定照片的本地ID列表，localId可以作为img标签的src属性显示图片
               $('#headPicture').attr('src', localIds);
           }
       });
   })
    $('.album').click(function(){
        wx.chooseImage({
            count: 1, // 默认9
            sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
            sourceType: ['album'], // 可以指定来源是相册还是相机，默认二者都有
            success: function (res) {
                var localIds = res.localIds; // 返回选定照片的本地ID列表，localId可以作为img标签的src属性显示图片
                $('#headPicture').attr('src', localIds);
            }
        });
    })
</script>
</body>
</html>